CREATE TABLE [dbo].[UspevKPTheme]
(
[idUspevDocs] [int] NOT NULL,
[KPTheme] [varchar] (255) COLLATE Cyrillic_General_CI_AS NOT NULL,
[DateReg] [datetime] NULL CONSTRAINT [DF_UspevKPTheme_dateReg] DEFAULT (getdate()),
[Options] [numeric] (4, 0) NULL,
[NReg] [int] NULL,
[DateRegOpt] [datetime] NOT NULL
)
CREATE NONCLUSTERED INDEX [idx_DateRegOpt] ON [dbo].[UspevKPTheme] ([DateRegOpt])

GO
ALTER TABLE [dbo].[UspevKPTheme] ADD CONSTRAINT [PK_UspevKPTheme] PRIMARY KEY CLUSTERED  ([idUspevDocs]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[UspevKPTheme] ADD CONSTRAINT [FK_UspevKPTheme_UspevDocument] FOREIGN KEY ([idUspevDocs]) REFERENCES [dbo].[UspevDocument] ([idUspevDocs])
GO
